<html>
<head><meta charset="utf-8"><title>Span of drop terminators · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html">Span of drop terminators</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201055656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201055656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201055656">(Jun 16 2020 at 18:28)</a>:</h4>
<p>I am working on <a href="https://github.com/rust-lang/rust/issues/72907">https://github.com/rust-lang/rust/issues/72907</a> and I started to poke the spans to see if i was able to get an span that matches the place where the dropping happens. I've tried to use the drop terminator's span to produce a second message:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(const_if_match)]</span><span class="w"></span>
<span class="cp">#![feature(const_loop)]</span><span class="w"></span>

<span class="k">const</span><span class="w"> </span><span class="n">_</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="kt">i32</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">never_returned</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="nb">Vec</span>::<span class="n">new</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">always_returned</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">None</span><span class="p">;</span><span class="w"></span>

<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">loop</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="n">always_returned</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">never_returned</span><span class="p">;</span><span class="w"></span>
<span class="w">     </span><span class="c1">// ^^^^^^^^^^^^^^^  location of the terminator</span>
<span class="w">        </span><span class="n">never_returned</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">None</span><span class="p">;</span><span class="w"></span>

<span class="w">        </span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="mi">10</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">break</span><span class="w"> </span><span class="n">always_returned</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>

<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</code></pre></div>


<p>However it seems it would be better to show the error one line after according to the comments in the issue? or is it OK to let the location for the message there and add a comment like "value is dropped after here".</p>



<a name="201108151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201108151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201108151">(Jun 17 2020 at 07:19)</a>:</h4>
<p>why one line after? This looks like the right location</p>



<a name="201108209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201108209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201108209">(Jun 17 2020 at 07:20)</a>:</h4>
<p>in the second loop iteration, <code>always_returned</code> is <code>Some</code> and thus overwritten with <code>None</code> and thus dropped</p>



<a name="201108319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201108319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201108319">(Jun 17 2020 at 07:22)</a>:</h4>
<p>oh right</p>



<a name="201108346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201108346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201108346">(Jun 17 2020 at 07:23)</a>:</h4>
<p>yeah I was focusing on the line number and apparently I got one line less somehow so I was confused</p>



<a name="201108359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201108359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201108359">(Jun 17 2020 at 07:23)</a>:</h4>
<p>But then I have a 2nd question :P</p>



<a name="201108768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201108768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201108768">(Jun 17 2020 at 07:28)</a>:</h4>
<p>How can I emit an error that involves more than one span inside <code>validation::Validator</code>?  Right now we're just calling <code>Validator::check_op_spanned(LiveDrop, span)</code> which just emits an error in <code>span</code>. I see no way of passing a second span to it or emit the error without "reimplementing" it</p>



<a name="201110335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201110335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201110335">(Jun 17 2020 at 07:50)</a>:</h4>
<p>hmm... you can give <code>LiveDrop</code> a field</p>



<a name="201110368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201110368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201110368">(Jun 17 2020 at 07:51)</a>:</h4>
<p>yep that's it</p>



<a name="201110369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201110369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201110369">(Jun 17 2020 at 07:51)</a>:</h4>
<p>thanks :P</p>



<a name="201110430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201110430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201110430">(Jun 17 2020 at 07:52)</a>:</h4>
<p>I was under the impression that the <code>NonConstOp</code> methods were all static</p>



<a name="201110481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201110481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201110481">(Jun 17 2020 at 07:53)</a>:</h4>
<p>:D this thing was <em>designed</em> it didn't grow</p>



<a name="201110633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Span%20of%20drop%20terminators/near/201110633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Span.20of.20drop.20terminators.html#201110633">(Jun 17 2020 at 07:55)</a>:</h4>
<p>heh</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>